package my.study.org.dom4j;


import java.io.File;
import java.util.List;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;


public class Dom4jTest {

	@SuppressWarnings("unchecked")
	public static void main(String[] args) throws DocumentException {
		SAXReader reader = new SAXReader();
		Document document = reader.read(new File("d:/1.xml"));
		Element root = document.getRootElement();
		List<Element> elements = root.elements();

		for (Element ele : elements) {
			System.out.println(ele.getName());
		}
		Element propEle = elements.get(0);
		List<Element> propEles = propEle.elements();
		for (Element ele : propEles) {
			System.out.println(" <property  value=\""
					+ ele.attributeValue("name") + "\" name=\""
					+ System.getProperty(ele.attributeValue("name").toString())
					+ "\"/>");
		}
	}
}
